package com.xian.figures.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xian.common.annotation.Log;
import com.xian.common.core.controller.BaseController;
import com.xian.common.core.domain.AjaxResult;
import com.xian.common.enums.BusinessType;
import com.xian.figures.domain.THistoricalFigures;
import com.xian.figures.service.ITHistoricalFiguresService;
import com.xian.common.utils.poi.ExcelUtil;
import com.xian.common.core.page.TableDataInfo;

/**
 * 历史人物信息Controller
 * 
 * @author jimihua
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/figures/figures")
public class THistoricalFiguresController extends BaseController
{
    @Autowired
    private ITHistoricalFiguresService tHistoricalFiguresService;

    /**
     * 查询历史人物信息列表
     */
    @PreAuthorize("@ss.hasPermi('figures:figures:list')")
    @GetMapping("/list")
    public TableDataInfo list(THistoricalFigures tHistoricalFigures)
    {
        startPage();
        List<THistoricalFigures> list = tHistoricalFiguresService.selectTHistoricalFiguresList(tHistoricalFigures);
        return getDataTable(list);
    }

    /**
     * 导出历史人物信息列表
     */
    @PreAuthorize("@ss.hasPermi('figures:figures:export')")
    @Log(title = "历史人物信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, THistoricalFigures tHistoricalFigures)
    {
        List<THistoricalFigures> list = tHistoricalFiguresService.selectTHistoricalFiguresList(tHistoricalFigures);
        ExcelUtil<THistoricalFigures> util = new ExcelUtil<THistoricalFigures>(THistoricalFigures.class);
        util.exportExcel(response, list, "历史人物信息数据");
    }

    /**
     * 获取历史人物信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('figures:figures:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tHistoricalFiguresService.selectTHistoricalFiguresById(id));
    }

    /**
     * 新增历史人物信息
     */
    @PreAuthorize("@ss.hasPermi('figures:figures:add')")
    @Log(title = "历史人物信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody THistoricalFigures tHistoricalFigures)
    {
        return toAjax(tHistoricalFiguresService.insertTHistoricalFigures(tHistoricalFigures));
    }

    /**
     * 修改历史人物信息
     */
    @PreAuthorize("@ss.hasPermi('figures:figures:edit')")
    @Log(title = "历史人物信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody THistoricalFigures tHistoricalFigures)
    {
        return toAjax(tHistoricalFiguresService.updateTHistoricalFigures(tHistoricalFigures));
    }

    /**
     * 删除历史人物信息
     */
    @PreAuthorize("@ss.hasPermi('figures:figures:remove')")
    @Log(title = "历史人物信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tHistoricalFiguresService.deleteTHistoricalFiguresByIds(ids));
    }
}
